//
//  MyAddressViewModel.m
//  LoveFreshBeen
//
//  Created by 胡不归是大虾 on 2016/10/20.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "MyAddressViewModel.h"
#import "NetWorkingTool.h"
#import <YYModel.h>
#import <SVProgressHUD.h>
#import "MyAdressModel.h"
@implementation MyAddressViewModel
+(instancetype)sharedAdressViewModel{
    static MyAddressViewModel* viewModel;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        viewModel = [[MyAddressViewModel alloc] init];
        [SVProgressHUD showWithStatus:@"正在加载数据..."];
    });
    return viewModel;
}
-(void)loadData:(void(^)(NSMutableArray*))finishedBlock{
    //@"12":@"MyAdress.json.php"
    [[NetWorkingTool shareInstance] getDatawithParam:@"12" WithUrlString:@"MyAdress.json.php" withSuccessBlock:^(id data) {
        NSArray* dictArray = data[@"data"];
        NSMutableArray* tempArray = [NSMutableArray array];
        for (NSDictionary* dict in dictArray) {
            MyAdressModel   *model = [[MyAdressModel alloc] init];
            [model yy_modelSetWithDictionary:dict];
            [tempArray addObject:model];
        }
        [SVProgressHUD dismiss];
        if (finishedBlock) {
            finishedBlock(tempArray);
        }
    } withFailedBlock:^(NSError *error) {

    } withErrorBlock:^(NSString *message) {

    }];
}
@end
